﻿/*
 * 由SharpDevelop创建。
 * 用户： xieen
 * 日期: 2013-08-14
 * 时间: 10:29
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Configuration;
using System.Reflection;

namespace GoF23Learning._04.Factory_Method.Refactor
{
	/// <summary>
	/// Description of Client.
	/// </summary>
	public class Client
	{
		public Client()
		{
		}
		public void WriteLog1()
		{
			EventLog log = new EventLog();
			log.Write();
		}
		public void WriteLog2()
		{
			LogFactory factory = new EventLogFactory();
			Log eventlog = factory.Create();
			eventlog.Write();
		}
		/// <summary>
		/// 读取App.config中配置
		/// </summary>
		public void WriteLog3()
		{
			string factoryName = ConfigurationManager.AppSettings["factoryName"];
			LogFactory factory ;
			factory = (LogFactory)Assembly.Load("GoF23Learning")
				.CreateInstance("GoF23Learning._04.Factory_Method.Refactor." + factoryName);
			
			Log eventlog = factory.Create();
			eventlog.Write();
		}
	}
}
